package com.hsp.throws_;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class ThrowsDetail {
    public static void main(String[] args) throws FileNotFoundException{
//        f1();
        f2();
    }
    //编译异常必须手动处理
    //运行时异常如果没有处理，会有默认处理，就是throws
    public static void f1() throws FileNotFoundException {
        FileInputStream fie = new FileInputStream("dfdsf");

    }
    //try-catch相当于处理异常，不throws也可以
    public static void f2() {
        try {
            int n1 = 0;
            int n2 = 10;
            int res = n2 / n1;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    //子类重写父类方法，子类抛出的异常必须是父类抛出的异常的子类, 或者一样


}

class father {
    public void method() throws RuntimeException{

    }
}

class Son extends father {
    @Override
    public void method() throws ArithmeticException{

    }
}